package org.Isaac.HelloWorld;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class HelloWorldActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Button bn = (Button)findViewById(R.id.ok);
        bn.setOnClickListener(new OnClickListener(){
        	public void onClick(View v)
        	{
        		final TextView show = (TextView)findViewById(R.id.show);
        		show.setText("Hello Android~"+ new java.util.Date());
        		Intent intent = new Intent("com.google.zxing.client.android.SCAN");
            	intent.putExtra("SCAN_MODE", "QR_CODE_MODE");
            	startActivityForResult(intent, 0);
        	}
        	public void onActivityResult(int requestCode, int resultCode, Intent intent) 
        	{
	        	 if (requestCode == 0) 
	        	 {
		        	 if (resultCode == RESULT_OK)
		        	 {
		        	 String contents = intent.getStringExtra("SCAN_RESULT");
		        	 String format = intent.getStringExtra("SCAN_RESULT_FORMAT");
		        	 // Handle successful scan
		        	 } 
		        	 else if (resultCode == RESULT_CANCELED) 
		        	 {
		        		 // Handle cancel
		        	 }
	        	 }
        	}
        	
        });
    }
}